package ru.amse.tsyganov.jumleditor.model;

import java.util.ArrayList;
import java.util.List;

/**
 * An activity graph is a special case of a state machine 
 * that defines a computational process in terms of the 
 * control-flow and object-flow among its constituent actions.
 * It does not extend the semantics of state machines in 
 * a major way but it does define shorthand forms that are 
 * convenient for modeling control-flow and object-flow in 
 * computational and organizational processes.
 * 
 * @author Dmitry Tsyganov
 *
 */
public class ActivityGraph extends ModelElement {	
	/**
	 * A set of Partitions each of which contains some of 
	 * the model elements of the model.
	 */
	private final List<Partition> partitions;
	
	public ActivityGraph() {
		partitions = new ArrayList<Partition>();
	}
	
	public void addPartition(Partition partition) {
		if (partition == null) {
			throw new IllegalArgumentException();
		}
		partitions.add(partition);
		partition.setActivityGraph(this);
	}
	
	public boolean removePartition(Partition partition) {
		if (partition == null) {
			throw new IllegalArgumentException();
		}
		return partitions.remove(partition);
	}
	
	public Iterable<Partition> getPartitions() {
		return partitions;
	}
}
